home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ue312src.zip / I55.C < prev    next >
C/C++ Source or Header  |  1992-01-10  |  5KB  |  276 lines

  1. /*
  2.  * The routines in this file provide support for ANSI style terminals
  3.  * over a serial line. The serial I/O services are provided by routines in
  4.  * termio.c. It compiles into nothing if not an ANSI device.
  5.  */
  6.  
  7. #define    termdef    1            /* don't define term external */
  8.  
  9. #include        <stdio.h>
  10. #include    "estruct.h"
  11. #include    "eproto.h"
  12. #include        "edef.h"
  13. #include    "elang.h"
  14.  
  15. #if     I55
  16.  
  17. #if    PROTO
  18. int PASCAL NEAR fnclabel(int f, int n);
  19. int PASCAL NEAR readparam( int *v);
  20. void PASCAL NEAR dobbnmouse(void);
  21. void PASCAL NEAR docsi( int oh);
  22. void PASCAL NEAR ttputs(char *string);
  23. #else
  24. int PASCAL NEAR fnclabel();
  25. int PASCAL NEAR readparam();
  26. void PASCAL NEAR dobbnmouse();
  27. void PASCAL NEAR docsi();
  28. void PASCAL NEAR ttputs();
  29. #endif
  30.  
  31. #define NROW    24                      /* Screen size.                 */
  32. #define NCOL    80                      /* Edit if you want to.         */
  33. #define    NPAUSE    100            /* # times thru update to pause */
  34. #define    MARGIN    8            /* size of minimim margin and    */
  35. #define    SCRSIZ    64            /* scroll size for extended lines */
  36. #define BEL     0x07                    /* BEL character.               */
  37. #define ESC     0x1B                    /* ESC character.               */
  38.  
  39. /* Forward references.          */
  40. extern int PASCAL NEAR i55move();
  41. extern int PASCAL NEAR i55eeol();
  42. extern int PASCAL NEAR i55eeop();
  43. extern int PASCAL NEAR i55beep();
  44. extern int PASCAL NEAR i55open();
  45. extern int PASCAL NEAR i55rev();
  46. extern int PASCAL NEAR i55close();
  47. extern int PASCAL NEAR i55kopen();
  48. extern int PASCAL NEAR i55kclose();
  49. extern int PASCAL NEAR i55cres();
  50. extern int PASCAL NEAR i55parm();
  51. extern int PASCAL NEAR i55getc();
  52.  
  53. #if    COLOR
  54. extern int PASCAL NEAR i55fcol();
  55. extern int PASCAL NEAR i55bcol();
  56.  
  57. static int cfcolor = -1;    /* current forground color */
  58. static int cbcolor = -1;    /* current background color */
  59. #endif
  60.  
  61. /*
  62.  * Standard terminal interface dispatch table. Most of the fields point into
  63.  * "termio" code.
  64.  */
  65. NOSHARE TERM term    = {
  66.     NROW-1,
  67.         NROW-1,
  68.         NCOL,
  69.         NCOL,
  70.     0, 0,
  71.     MARGIN,
  72.     SCRSIZ,
  73.     NPAUSE,
  74.         i55open,
  75.         i55close,
  76.     i55kopen,
  77.     i55kclose,
  78.         i55getc,
  79.         ttputc,
  80.         ttflush,
  81.         i55move,
  82.         i55eeol,
  83.         i55eeop,
  84.         i55eeop,
  85.         i55beep,
  86.     i55rev,
  87.     i55cres
  88. #if    COLOR
  89.     , i55fcol,
  90.     i55bcol
  91. #endif
  92. };
  93.  
  94. #if    COLOR
  95. PASCAL NEAR i55fcol(color)        /* set the current output color */
  96.  
  97. int color;    /* color to set */
  98.  
  99. {
  100.     color = color & 7;
  101.     if (color == cfcolor)
  102.         return;
  103.     ttputc(ESC);
  104.     ttputc('[');
  105.     i55parm(color+30);
  106.     ttputc('m');
  107.     cfcolor = color;
  108. }
  109.  
  110. PASCAL NEAR i55bcol(color)        /* set the current background color */
  111.  
  112. int color;    /* color to set */
  113.  
  114. {
  115.     color = color & 7;
  116.     if (color == cbcolor)
  117.         return;
  118.     ttputc(ESC);
  119.     ttputc('[');
  120.     i55parm(color+40);
  121.     ttputc('m');
  122.         cbcolor = color;
  123. }
  124. #endif
  125.  
  126. PASCAL NEAR i55move(row, col)
  127. {
  128.         ttputc(ESC);
  129.         ttputc('[');
  130.         i55parm(row+1);
  131.         ttputc(';');
  132.         i55parm(col+1);
  133.         ttputc('H');
  134. }
  135.  
  136. PASCAL NEAR i55eeol()
  137. {
  138.         ttputc(ESC);
  139.         ttputc('[');
  140.         ttputc('K');
  141. }
  142.  
  143. PASCAL NEAR i55eeop()
  144. {
  145. #if    COLOR
  146.     i55fcol(gfcolor);
  147.     i55bcol(gbcolor);
  148. #endif
  149.         ttputc(ESC);
  150.         ttputc('[');
  151.         ttputc('J');
  152. }
  153.  
  154. PASCAL NEAR i55rev(state)        /* change reverse video state */
  155.  
  156. int state;    /* TRUE = reverse, FALSE = normal */
  157.  
  158. {
  159. #if    COLOR
  160.     int ftmp, btmp;        /* temporaries for colors */
  161. #endif
  162.  
  163.     ttputc(ESC);
  164.     ttputc('[');
  165.     ttputc(state ? '7': '0');
  166.     ttputc('m');
  167. #if    COLOR
  168.     if (state == FALSE) {
  169.         ftmp = cfcolor;
  170.         btmp = cbcolor;
  171.         cfcolor = -1;
  172.         cbcolor = -1;
  173.         i55fcol(ftmp);
  174.         i55bcol(btmp);
  175.     }
  176. #endif
  177. }
  178.  
  179. PASCAL NEAR i55cres()    /* change screen resolution */
  180.  
  181. {
  182.     return(TRUE);
  183. }
  184.  
  185. #if    PROTO
  186. PASCAL NEAR spal(char *dummy)        /* change pallette settings */
  187. #else
  188. PASCAL NEAR spal(dummy)        /* change pallette settings */
  189.  
  190. char *dummy;
  191. #endif
  192.  
  193. {
  194.     /* none for now */
  195. }
  196.  
  197. PASCAL NEAR i55beep()
  198. {
  199.         ttputc(BEL);
  200.         ttflush();
  201. }
  202.  
  203. PASCAL NEAR i55parm(n)
  204. register int    n;
  205. {
  206.         register int q,r;
  207.  
  208.         q = n/10;
  209.         if (q != 0) {
  210.         r = q/10;
  211.         if (r != 0) {
  212.             ttputc((r%10)+'0');
  213.         }
  214.         ttputc((q%10) + '0');
  215.         }
  216.         ttputc((n%10) + '0');
  217. }
  218.  
  219. PASCAL NEAR i55open()
  220. {
  221.     strcpy(sres, "NORMAL");
  222.     revexist = TRUE;
  223.         ttopen();
  224.  
  225. #if    KEYPAD
  226.     ttputc(ESC);
  227.     ttputc('=');
  228. #endif
  229. }
  230.  
  231. PASCAL NEAR i55close()
  232.  
  233. {
  234. #if    COLOR
  235.     i55fcol(7);
  236.     i55bcol(0);
  237. #endif
  238. #if    KEYPAD
  239.     ttputc(ESC);
  240.     ttputc('>');
  241. #endif
  242.     ttclose();
  243. }
  244.  
  245. PASCAL NEAR i55kopen()    /* open the keyboard (a noop here) */
  246.  
  247. {
  248. }
  249.  
  250. PASCAL NEAR i55kclose()    /* close the keyboard (a noop here) */
  251.  
  252. {
  253. }
  254.  
  255. PASCAL NEAR  i55getc()
  256.  
  257. {
  258.     return(ttgetc());
  259. }
  260.  
  261. #if    FLABEL
  262. int PASCAL NEAR fnclabel(f, n)        /* label a function key */
  263.  
  264. int f,n;    /* default flag, numeric argument [unused] */
  265.  
  266. {
  267.     /* on machines with no function keys...don't bother */
  268.     return(TRUE);
  269. }
  270. #endif
  271. #else
  272. i55hello()
  273. {
  274. }
  275. #endif
  276.